import static java.lang.Thread.sleep;

class MyThread extends Thread {
    @Override
    public void run() {
        while(true) {

            System.out.println("MyThread");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}


public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new MyThread();
        t1.start();

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    System.out.println("t2");
                    try {
                        sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        t2.start();

        Thread t3 = new Thread(()->{
            while(true) {

                System.out.println("t3");
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t3.start();
        while(true) {
            System.out.println("main");
            sleep(1000);
        }
    }
}
